package org.example.javademo.test08.demo2;

/**
 * 小偷
 * @author gwf
 * @date 2025-03-04
 */
public class Thief {
    private Door door;
    public Thief(Door door) {
        this.door = door;
    }
    public void steal() {
        if(door instanceof SecurityDoor){
            ((SecurityDoor) door).antiBells();
            System.out.println("小偷触发响铃,偷盗失败");
        }else {
            if(Math.random()<0.5){
                System.out.println("小偷偷盗成功");
            }else {
                System.out.println("小偷偷盗失败");
            }
        }

    }
}
